/* Copyright © 2009 sample Computer Corporation Limited
 * All rights reserved.
 * 
 * Date: 2009-4-13
 * author: fungus  (fungus@gmail.com)
 *
 */
package com.glodon.ggzy.core.utils;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import com.glodon.ggzy.core.model.BaseModel;
import com.glodon.ggzy.webservice.Unit;

/**
 * 
 * 
 * 查询的model需要继承此类
 * 
 * @author yangjf
 * @since jdk1.6
 * @date 2013-6-17
 * 
 */
public class PageSearchModel extends BaseModel {

	private int pageNo = Constants.DEFAULT_PAGE_NUM;

	private int pageSize = Constants.DEFAULT_PAGE_SIZE;

	private String[] params;

	private Map<String, Object> paramsMap = new HashMap<String,Object>();
	
	private HttpSession session;
	
	private String orgCode;

	public PageSearchModel() {

	}

	public PageSearchModel(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public String[] getParams() {
		return params;
	}

	public void setParams(String[] params) {
		this.params = params;
	}

	public void addParamToMap(String key,Object value){
		this.paramsMap.put(key, value);
	}
	
	public void removeAllParamOfMap(){
		this.paramsMap.clear();
	}

	public Map<String, Object> getParamsMap() {
		return paramsMap;
	}

	public void setParamsMap(Map<String, Object> paramsMap) {
		this.paramsMap = paramsMap;
	}

	public String getOrgCode() {
		
		if(getSession() == null){
			throw new RuntimeException("请设置session");
		}
		
		Unit attribute = (Unit) session.getAttribute(Constants.user_session_key);

		//如果没有用户信息，列表显示为空
		if(attribute!=null)
			return attribute.getOrganizationCode();
		else
			return "@none@!!$";
		
	}

	public HttpSession getSession() {
		return session;
	}

	public void setSession(HttpSession session) {
		this.session = session;
	}
	
	

}
